addEvent("onInterakcjeWybierzAkcje", true)
addEventHandler("onInterakcjeWybierzAkcje", getRootElement(),
function(id, vehicle)
local veh = getPedOccupiedVehicle(source)
local recznySalon = getElementData(veh,"veh:salon")
local recznyPraca = getElementData(veh,"vehicle.praca")
	if veh then
		if getVehicleController(veh) == source then
			if id == 1 then
		    triggerClientEvent ( source, "startsilnika", source )
			setTimer(function()
			setVehicleEngineState(veh, true)
			end,1000,1)
			elseif id == 2 then
			setVehicleEngineState(veh, false)
			elseif id == 3 then
			setVehicleOverrideLights(veh, 2)
			elseif id == 4 then
			setVehicleOverrideLights(veh, 1)
			elseif id == 5 then
			setVehicleLocked(veh,false)
			elseif id == 6 then
			setVehicleLocked(veh,true)
		    elseif id == 9 then
			setVehicleDoorOpenRatio(veh,0,1,2000)
		    elseif id == 10 then
			setVehicleDoorOpenRatio(veh,0,0,2000)
            elseif id == 11 then
			setVehicleDoorOpenRatio(veh,1,1,2000)
			elseif id == 12 then
			setVehicleDoorOpenRatio(veh,1,0,2000)
            elseif id == 13 then
            setElementData(veh,"pasyzapiete",false)			
            elseif id == 14 then
            setElementData(veh,"pasyzapiete",true)
            elseif id == 15 then 
            setElementData(veh, "vehicle:LPGWloczone", false)
            setElementData(veh, "vehicle:BezynaWloczone", true)
		    elseif id == 16 then
            setElementData(veh, "vehicle:LPGWloczone", true)
            setElementData(veh, "vehicle:BezynaWloczone", false)			
   			elseif id == 7 then
			if recznySalon then 
					 exports.rpg_noti:createNotification(source, "x", "Interakcja nie działa na pojazd z salonu!")
         return 
end
			if recznyPraca then 
                     outputChatBox("* Nie możesz spuscić ręcznego!",source,255,0,0) 
         return 
end
			setElementFrozen(veh, false)
			elseif id == 8 then
local sx,sy,sz = getElementVelocity(veh)
local kmhs = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
if kmhs < 20 then
if getElementModel(source) == 574 then return end
			setElementFrozen(veh, true)
			end
		end
	else
		if vehicle then
			if isElement(vehicle) then
				if isVehicleLocked(vehicle) then
				setVehicleLocked(vehicle, false)
				else
				setVehicleLocked(vehicle, false)
				end
			end
		end
	end
end
end)

addEventHandler ( "onPlayerVehicleExit", getRootElement(), function(theVehicle, leftSeat, jackerPlayer)
    if leftSeat == 0 and not jackerPlayer then
      setVehicleLocked(theVehicle, false)
	  setElementData(theVehicle,"pasyzapiete",false)
	end
end)

